import * as echarts from "echarts";
function linfn(item, data) {
    var myChart = echarts.init(item);
    if (myChart) {
        var option;
        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        show: false
                    }
                }
            },
            grid: {
                left: '0%',
                top: '5%',
                right: '1%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    boundaryGap: false,
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                }
            ],
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: 'Search Engine',
                    type: 'line',
                    stack: 'Total',
                    smooth: true,
                    lineStyle: {
                        width: 1.1
                    },
                    label: {
                        show: true,
                        position: 'top'
                    },
                    showSymbol: false,
                    areaStyle: {
                        opacity: 0.8,
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                            {
                                offset: 0,
                                color: 'rgb(0, 221, 255,0.3)'
                            },
                            {
                                offset: 1,
                                color: 'rgb(77, 119, 255,0.6)'
                            }
                        ])
                    },
                    emphasis: {
                        focus: 'series'
                    },
                    data: data
                },
            ]
        }
        option && myChart.setOption(option);
    } else {

    }

    window.addEventListener('resize', () => {
        setTimeout(() => {
            myChart.resize()
        }, 100)
    })

}

export { linfn }